#ifndef OCTASKDIR_H_INCLUDED
#define OCTASKDIR_H_INCLUDED

#include <glib.h>

#include "octask.h"

typedef struct
{
    //GArray*   task_array;
    oc_task_t    *task_array;
    guint32      ntasks;
}oc_task_dir_t;

static inline
void oc_task_dir_init ( oc_task_dir_t   *task_dir,
                        guint32         ntasks  )
{
    /*task_dir->task_array = g_array_sized_new ( FALSE,
                                                FALSE,
                                                sizeof ( oc_task_t ),
                                                ntasks );*/
    task_dir->task_array = g_new ( oc_task_t, ntasks );
    task_dir->ntasks = ntasks;
/*
    guint32 i;
    for ( i = 0; i < ntasks; ++i )
    {
        //oc_task_t *task = g_new( oc_task_t, 1 );
        g_array_append_vals ( task_dir->task_array,
                                g_new( oc_task_t, 1 ),
                                1                       );
    }*/
}

static inline
guint32 oc_task_dir_get_num_tasks ( oc_task_dir_t   *task_dir )
{
    return task_dir->ntasks;
}


static inline
oc_task_t *oc_task_dir_get_task ( oc_task_dir_t   *task_dir,
                                guint32         i )
{
    /*return & g_array_index (   task_dir->task_array,
                                oc_task_t,
                                i );*/
    return & task_dir->task_array[i];
}

static inline
void oc_task_dir_destroy ( oc_task_dir_t   *task_dir
                        )
{
    /*guint32 i;
    for ( i = 0; i < ntasks; ++i )
    {
        g_free ( oc_task_dir_get_task ( task_dir, i )   );
    }
    g_array_unref ( task_dir->task_array );*/
    g_free ( task_dir->task_array );
}

#endif // OCTASKDIR_H_INCLUDED
